import axios from "axios";
import http from "../../../http";
import uuid from "../../../sdk/module/uuid";

export async function uploadFile(file: File,fileName:string): Promise<boolean> {
    try {
    
        const response = await http.get("/getMinioUrl?filename=" + fileName);
        const url = response.data;

        const uploadResponse = await axios.put(url, file, {
            headers: {
                'Content-Type': file.type
            }
        });

        console.log('File uploaded successfully:', uploadResponse.status);
        return true; // 上传成功返回 true
    } catch (error) {
        console.error('Error uploading file:', error);
        return false; // 上传失败返回 false
    }
}